package com.hl.controller;


import com.hl.domain.SearchExpert;
import com.hl.service.SearchExpertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/search/experts")
public class SearchExpertController {
    @Autowired
    private SearchExpertService searchExpertService;

    @GetMapping("/getExperts")
    public ResponseEntity<Map<String, Object>> searchExperts(@RequestParam String query) {
        List<SearchExpert> experts = searchExpertService.searchExperts(query);

        // 由于 Mapper 已经处理了擅长领域的合并，这里不需要再次合并
        // 我们只需要将结果包装到一个 Map 中返回
        Map<String, Object> response = new HashMap<>();
        response.put("experts", experts);

        return ResponseEntity.ok(response);
    }
}
